<template>
	<view>
		<view class="history">
			<view class="top">
				<view class="txt">历史记录</view>
				<u-icon name="trash" size="20" @tap="clearFn"></u-icon>
			</view>
			<view class="bottom">
				<view  v-for="(item,index) in $store.state.secrch.historyKeywordList" :key="index">
					<u-button type="primary" :plain="true" :text="item" color="#999" size="mini"></u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from "vuex"
	import {ApiGetClearhistoryData} from "@/utils/api.js"
export default {
	name: 'history',
	data() {
		return {};
	},
	methods:{
		async clearFn(){
			let res =await ApiGetClearhistoryData();
			// console.log(res);
	this.$store.state.secrch.historyKeywordList=""
			uni.showToast({
				icon:"success",
				title:"删除成功"
			})
		}
	}
};
</script>

<style lang="less">
.history {
	background-color: #fff;
	padding: 30rpx;
	padding-top: 0;
	.top {
		display: flex;
		justify-content: space-between;
		padding-bottom: 20rpx;
	}
	.bottom {
		display: flex;
flex-wrap: wrap;
		.u-button {
			width: auto;
			margin: 0;
			margin-right: 20rpx;
			margin-bottom: 20rpx;
		}
	}
}
</style>
